package com.lambda;

import java.util.function.BiFunction;
import java.util.function.BinaryOperator;

public class Lambda_1 {


    public static void test1(Par2 s){
        s.test();
    };

    public static void main(String[] args) {
        Lambda_1.test1(()-> System.out.println("hello lambda"));
        BinaryOperator<Integer> sum1 = (Integer x, Integer y) -> x + y;
        //类型推断
        BinaryOperator<Integer> sum2 = ( x,  y) -> x + y;
        //与BinaryOperator<Integer>相同
        BiFunction<Integer,Integer,Integer> sum3 = (x, y) -> x + y;

        /*Lambda 表达式中引用既成事实上的 final 变量
        未使用既成事实上的 final 变量,导致无法通过编译*/
        String name = "sys";
//        name = "hello";
        Lambda_1.test1(()-> System.out.println(name));
//        name = "helll";

    }

}

